using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Category("Physics")]
	[AgentType(typeof(Transform))]
	public class GetLinecastInfo : ActionTask
	{
		[RequiredField]
		public BBGameObject target;

		public LayerMask mask = -1;

		[BlackboardOnly]
		public BBGameObject saveHitGameObjectAs;

		[BlackboardOnly]
		public BBFloat saveDistanceAs;

		[BlackboardOnly]
		public BBVector savePointAs;

		[BlackboardOnly]
		public BBVector saveNormalAs;

		private RaycastHit hit = default(RaycastHit);

		protected override void OnExecute()
		{
			if (Physics.Linecast(base.agent.transform.position, target.value.transform.position, out hit, mask))
			{
				saveHitGameObjectAs.value = hit.collider.gameObject;
				saveDistanceAs.value = hit.distance;
				savePointAs.value = hit.point;
				saveNormalAs.value = hit.normal;
				EndAction(true);
			}
			else
			{
				EndAction(false);
			}
		}

		protected override void OnGizmosSelected()
		{
			if ((bool)base.agent && (bool)target.value)
			{
				Gizmos.DrawLine(base.agent.transform.position, target.value.transform.position);
			}
		}
	}
}
